package com.czl.module_user.adapter

import android.os.Bundle
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.czl.base.base.BaseFragment
import com.czl.base.binding.command.BindingCommand
import com.czl.base.binding.command.BindingConsumer
import com.czl.base.config.AppConstants
import com.czl.base.data.bean.MonthCardListBean
import com.czl.base.data.bean.RepairBean
import com.czl.module_user.R
import com.czl.module_user.databinding.ItemPeopleBinding
import com.czl.module_user.databinding.ItemScoreBinding
import com.czl.module_user.fragment.PeopleManagerFragment

/**
 *
 * @Description:
 * @Author: XCH
 * @CreateDate: 2021/12/10 11:38
 */
class PeopleAdapter(private val fragment: PeopleManagerFragment) :
    BaseQuickAdapter<RepairBean, BaseDataBindingHolder<ItemPeopleBinding>>(
        R.layout.item_people
    ) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemPeopleBinding>,
        item: RepairBean
    ) {
        holder.dataBinding?.apply {
            data = item
            adapter = this@PeopleAdapter
            executePendingBindings()
        }
    }

    val onRenewClick: BindingCommand<Any> = BindingCommand(BindingConsumer {
        if (it is RepairBean) {
//            fragment.startContainerActivity(AppConstants.Router.Park.F_RENEW_CARD, Bundle().apply {
//                putSerializable(AppConstants.BundleKey.MONTH_CARD_DATA, it)
//            })
        }
    })

    val onDeleteClick: BindingCommand<Any> = BindingCommand(BindingConsumer {
        if (it is RepairBean) {
            fragment.viewModel.uc.deleteEvent.postValue(it.no)
//            fragment.startContainerActivity(AppConstants.Router.Park.F_RENEW_CARD, Bundle().apply {
//                putSerializable(AppConstants.BundleKey.MONTH_CARD_DATA, it)
//            })
        }
    })
}